bitkeeper revision 1.289.2.2 (3f0a897bGzUUM0kzMiUA41zn4irydw)
authorsos22@labyrinth.cl.cam.ac.uk <sos22@labyrinth.cl.cam.ac.uk>
Tue, 8 Jul 2003 09:06:03 +0000 (09:06 +0000)
committersos22@labyrinth.cl.cam.ac.uk <sos22@labyrinth.cl.cam.ac.uk>
Tue, 8 Jul 2003 09:06:03 +0000 (09:06 +0000)
Find domains using find_domain_by_id rather than by looping over
the task list.

xen/drivers/block/xen_physdisk.c
xen/drivers/block/xen_segment.c

index e0d697bd663e4b25cec56612c532a63fe4eea03b..c5d2deb82a491bce6a8b377f7b6b6bc95522dffd 100644 (file)
@@ -188,10 +188,8 @@ int xen_physdisk_grant(xp_disk_t *xpd_in)
   DPRINTK("Have current.\n");
   DPRINTK("Target domain %x\n", xpd->domain);
 
-  do {
-    p = p->next_task;
-  } while (p != current && p->domain != xpd->domain);
-  if (p->domain != xpd->domain) {
+  p = find_domain_by_id(xpd->domain);
+  if (p == NULL) {
     DPRINTK("Bad domain!\n");
     res = 1;
     goto out;
@@ -203,6 +201,7 @@ int xen_physdisk_grant(xp_disk_t *xpd_in)
                                  xpd->mode,
                                  p);
   spin_unlock(&p->physdev_lock);
+  put_task_struct(p);
 
  out:
   unmap_domain_mem(xpd);
@@ -216,16 +215,14 @@ int xen_physdisk_probe(struct task_struct *requesting_domain,
   physdisk_probebuf_t *buf = map_domain_mem(virt_to_phys(buf_in));
   int res;
 
-  p = current;
-  do {
-    p = p->next_task;
-  } while (p != current && p->domain != buf->domain);  
-  if (p->domain != buf->domain) {
+  if (requesting_domain->domain != 0 &&
+      requesting_domain->domain != buf->domain) {
     res = 1;
     goto out;
   }
-  if (requesting_domain->domain != 0 &&
-      requesting_domain->domain != buf->domain) {
+
+  p = find_domain_by_id(buf->domain);
+  if (p == NULL) {
     res = 1;
     goto out;
   }
@@ -233,6 +230,8 @@ int xen_physdisk_probe(struct task_struct *requesting_domain,
   spin_lock(&p->physdev_lock);
   xen_physdisk_probe_access(buf, p);
   spin_unlock(&p->physdev_lock);
+  put_task_struct(p);
+
   res = 0;
  out:
   unmap_domain_mem(buf);
index 6691eecb0e7d6cfe39680210baa3f59e8d7ed246..2f110423f0145b06acbe54ed27465b8bbd86632c 100644 (file)
@@ -250,15 +250,11 @@ int xen_segment_create(xv_disk_t *xvd_in)
     }
 
     /* if the domain exists, assign the segment to the domain */
-    p = current;
-    do
-    {
-        p = p->next_task;
-    } while (p != current && p->domain != xvd->domain);
-
-    if (p->domain == xvd->domain)
+    p = find_domain_by_id(xvd->domain);
+    if (p != NULL)
     {
         p->segment_list[xvd->segment] = &xsegments[idx];
+        put_task_struct(p);
     }
 
     unmap_domain_mem(xvd);